<template>
  <!-- <transition name="van-slide-right">
  <router-view></router-view>
  </transition> -->

  <router-view v-slot="{ Component }">
    <transition name="van-slide-right">
        <component :is="Component" />
    </transition>
  </router-view>
</template>
<script>
// import { useStore } from "vuex";
export default {
  name: "App",
  created() {
    // console.log('111')
    //在页面加载时读取sessionStorage里的状态信息
    if (sessionStorage.getItem("store")) {
      // console.log('页面',this.$store.state);
      this.$store.replaceState(
        Object.assign({}, this.$store.state, JSON.parse(sessionStorage.getItem("store")))
      );
    }
    //在页面刷新时将vuex里的信息保存到sessionStorage里
    window.addEventListener("beforeunload", () => {
      // console.log('///////',this.$store.state);
      sessionStorage.setItem("store", JSON.stringify(this.$store.state));
    });
  },
};
</script>

<style>
* {
  margin: 0;
  padding: 0;
}
</style>
